package com.fivec.javaproject.service;

import com.alibaba.fastjson.JSONObject;
import com.fivec.javaproject.Constants;
import com.fivec.javaproject.bean.HotVideo;
import com.fivec.javaproject.bean.HotVideoCommon;
import com.fivec.javaproject.net.HttpUtils;

import java.util.List;

/**
 * @author wangyizhu
 * @version "1.8.0_131"
 * @email 2641956765@qq.com
 * @desc:该类创建了获取热门数据的方法
 * @Time 2021/12/06 14:33
 */
public class HotVideService {
    /**
     * 该方法用于获取热门数据，并将热门数据返回
     *
     * @param
     * @return List<HotVideo>
     */
    public List<HotVideo> getHotVideo() {
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=5";
        String result = HttpUtils.get(url);
        //System.out.println(result);
        //json解析
        HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);
        //System.out.println(videoCommon.result.size());
        return videoCommon.result;

    }
}
